package com.ubs.web.diagnostic.imp;

import java.util.ArrayList;
import java.util.List;

import com.ubs.dom.Account;
import com.ubs.dom.Service;
import com.ubs.ejb.AccountControllerLocal;
import com.ubs.ejb.ServiceControllerLocal;
import com.ubs.web.diagnostic.core.AbstractTestStep;
import com.ubs.web.diagnostic.core.TestStep;
import com.ubs.web.diagnostic.core.TestSuite;
import com.ubs.web.diagnostic.exception.DiagnosticException;

public class ServiceControllerTestSuite implements TestSuite {
	
	@Override
	public String getSuiteName() {
		return "ServiceController suite ";
	}

	private final TestStep serviceBeanTest = new AbstractTestStep("ServiceControllerBean obtaining") {
		
		@Override
		public void testBody() throws DiagnosticException {
			DiagnosticBeanFactory.getServiceControllerBean();
		}
	};

	private final TestStep getPrimaryServicesTest = new AbstractTestStep("Primary services obtaining") {
		
		@Override
		public void testBody() throws DiagnosticException {
			ServiceControllerLocal bean = DiagnosticBeanFactory.getServiceControllerBean();
			
			List<Service> primaryServices = bean.getPrimaryServices(false);
 			if (primaryServices.size() != 1) {
 				throw new DiagnosticException("primaryServices.size() != 1");
 			}
		}
	};
	
	@Override
	public List<TestStep> getTestSteps() {
		List<TestStep> list = new ArrayList<TestStep>();
		
		list.add(serviceBeanTest);
		
		list.add(getPrimaryServicesTest);
		return list;
	}

}
